import { reqBannerList,reqCategoryList,reqFloorList } from "@/api";

const state = {
  categoryList: [],
  bannerList: [],
  floorList: [],
}

const mutations = {
  SET_CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList
  },
  SET_BANNERLIST(state,bannerList) {
    state.bannerList = bannerList
  },
  SET_FLOORLIST(state,floorList) {
    state.floorList = floorList
  },
}

const actions = {
  async getCategoryList({ commit }) {
    try {
      let res = await reqCategoryList()
      commit('SET_CATEGORYLIST',res.data)
    } catch (error) {
      console.error(error);
    }
  },
  async getBannerList({ commit }) {
    try {
      let res = await reqBannerList()
      commit('SET_BANNERLIST',res.data)
    } catch (error) {
      console.error(error);
    }
  },
  async getFloorList({ commit }) {
    try {
      let res = await reqFloorList()
      commit('SET_FLOORLIST',res.data)
    } catch (error) {
      console.error(error);
    }
  },
}

const getters = {}

export default {
  state,
  mutations,
  actions,
  getters,
}